package com.s63.ssm.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.s63.ssm.valid.AddGroup;
import com.s63.ssm.valid.UpdateGroup;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.Date;
import java.util.List;

/**
 * 系统用户类
 * @author project.cvs.team
 */
public class SysUser implements java.io.Serializable {
	@NotNull(message = "ID不能为空", groups = UpdateGroup.class)
	private Integer id; 			//id

	@NotEmpty(message = "账号不能为空")
	private String account; 		//账号
	private String password; 		//密码
	@Size(message = "长度在3到8之间", max = 8, min = 3, groups = {AddGroup.class, UpdateGroup.class})
	private String realName; 		//真实姓名
	private Integer roleId;	    	//角色id
	private String phone;   		//电话
	private String address; 		//地址

	@NotNull(message = "性别不能为空", groups = AddGroup.class)
	private Integer sex;	 		//性别
//	@DateTimeFormat(pattern = "yyyy-MM-dd")
//	@JSONField(format = "yyyy.MM.dd")
	@JsonFormat(pattern = "yyyy.MM.dd")
	private Date birthday;  		//出生日期
	private Integer createdUserId; 	//创建人id
	private Date createdTime; 		//创建时间
	private Integer updatedUserId; 	//修改人id
	private Date updatedTime;   	//修改时间

	private String userRoleName; // 角色名字

	private SysRole sysRole; // 角色对象

	private List<Address> addresses; //地址集合

	private Integer age;			//用户年龄
	private String idPicPath;
	private String workPicPath;

	public String getIdPicPath() {
		return idPicPath;
	}

	public void setIdPicPath(String idPicPath) {
		this.idPicPath = idPicPath;
	}

	public String getWorkPicPath() {
		return workPicPath;
	}

	public void setWorkPicPath(String workPicPath) {
		this.workPicPath = workPicPath;
	}

	public List<Address> getAddresses() {
		return addresses;
	}

	public void setAddresses(List<Address> addresses) {
		this.addresses = addresses;
	}

	public SysRole getSysRole() {
		return sysRole;
	}

	public void setSysRole(SysRole sysRole) {
		this.sysRole = sysRole;
	}

	public String getUserRoleName() {
		return userRoleName;
	}

	public void setUserRoleName(String userRoleName) {
		this.userRoleName = userRoleName;
	}

	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	
	public String getRealName() {
		return realName;
	}
	public SysUser setRealName(String realName) {
		this.realName = realName;
		return this;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getAccount() {
		return account;
	}
	public SysUser setAccount(String account) {
		this.account = account;
		return this;
	}
	public Integer getRoleId() {
		return roleId;
	}
	public SysUser setRoleId(Integer role) {
		this.roleId = role;
		return this;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public Integer getSex() {
		return sex;
	}
	public void setSex(Integer sex) {
		this.sex = sex;
	}
	public Date getBirthday() {
		return birthday;
	}
	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}
	public Integer getCreatedUserId() {
		return createdUserId;
	}
	public void setCreatedUserId(Integer createdUserId) {
		this.createdUserId = createdUserId;
	}
	public Date getCreatedTime() {
		return createdTime;
	}
	public void setCreatedTime(Date createdTime) {
		this.createdTime = createdTime;
	}
	public Integer getUpdatedUserId() {
		return updatedUserId;
	}
	public void setUpdatedUserId(Integer updatedUserId) {
		this.updatedUserId = updatedUserId;
	}
	public Date getUpdatedTime() {
		return updatedTime;
	}
	public void setUpdatedTime(Date updatedTime) {
		this.updatedTime = updatedTime;
	}
	public void setAge(Integer age) {
		this.age = age;
	}

	public Integer getAge() {
		if (birthday != null) {
			Date date = new Date();
			Integer age = date.getYear()-birthday.getYear();
			return age;
		}
		return 0;
	}


}
